package edu.corn.common.monitor;

import cn.hutool.core.thread.ThreadUtil;

import java.util.concurrent.ExecutorService;

public class ThreadPoolFactory {

    // 创建固定大小的线程池
    public static ExecutorService createFixedThreadPool(int nThreads, String threadNamePrefix) {
        return ThreadUtil.newFixedExecutor(nThreads, threadNamePrefix, false);
    }


    // 创建单线程池
    public static ExecutorService createSingleThreadExecutor() {
        return ThreadUtil.newSingleExecutor();
    }

    // 创建自定义配置的线程池
    public static ExecutorService createCustomThreadPool(int corePoolSize, int maximumPoolSize, int maximumQueueSize) {
        return ThreadUtil.newExecutor(corePoolSize, maximumPoolSize, maximumQueueSize);
    }


}
